package com.th.supcom.pds.sortingdrug.client.mvc;

import net.carefx.fc.component.editor.client.EMREditorPanel;
import net.carefx.framework.container.client.page.PageContext;

import com.extjs.gxt.ui.client.Style.HideMode;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.th.supcom.framework.print.client.PrintUtils;
import com.th.supcom.pds.sortingdrug.client.common.SortingDrugModuleEvents;
import com.th.supcom.pds.sortingdrug.client.widget.SortingDrugMainPanel;

/**
 * PhamBasicInfo视图.
 * 
 * 药品信息.
 */
public class SortingDrugView extends View
{

    /** 公司版权信息. */
    public static final String copyright = "Copyright 2014, TH Supcom Corporation";

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";

    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";

    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";

    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";

    /** 主面板. */
    private SortingDrugMainPanel m_sortingDrugMainPanel;

    /**
     * @param controller
     */
    public SortingDrugView (final Controller controller)
    {
        super (controller);
    }

    @Override
    protected void handleEvent (final AppEvent event)
    {
        if (SortingDrugModuleEvents.UI_INIT.equals (event.getType ()))
        {
            final PageContext context = event.getData ();
            this.initUI (context);
            return;
        }
    }

    /**
     * 初始化容器面板.
     * 
     * @param context
     */
    private void initUI (final PageContext context)
    {
        EMREditorPanel editorPanel;
        final LayoutContainer mainLayoutContainer = context.getContainer ();
        mainLayoutContainer.setLayout (new FitLayout ());
        mainLayoutContainer.setHideMode (HideMode.OFFSETS);
        m_sortingDrugMainPanel = new SortingDrugMainPanel ();
        editorPanel = PrintUtils.createReportPanel ();
        mainLayoutContainer.add (m_sortingDrugMainPanel);
        mainLayoutContainer.add (editorPanel);

    }

    private void onprintInfo ()
    {
        // TODO Auto-generated method stub
        // PrintUtils.printReceiptInvoice (m_editorPanel, "", null);
        // PrintViewType.preview, null, null);

    }
}
